package test.socket.http;

import java.io.*;
import java.net.Socket;

public class HttpCient {
    public static void main(String[] args) throws InterruptedException {
        try {
            Socket socket = new Socket("localhost",8888);
            OutputStream outputStream = socket.getOutputStream();
            FileInputStream fis = new FileInputStream(new File("movie/1.mp3"));
            byte[] bys = new byte[1024];
            int len =0;
            System.out.println("开始上传！！！！！");
            while ((len=fis.read(bys))!=-1){
                outputStream.write(bys,0,len);
                outputStream.flush();
            }
            outputStream.write("end".getBytes());
            System.out.println("上传结束");
            InputStream inputStream = socket.getInputStream();
            DataInputStream dataInputStrea  = new DataInputStream(inputStream);
            System.out.println(dataInputStrea.readUTF());
            //System.out.println(new String(bys,0,12));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
